package practice.unionfind;

/**
 * @Description:
 * @Author Ammar
 * @Create 2023/8/26 19:48
 */
public class QuickUnion_rank_compression extends QuickUnion_rank {
    public QuickUnion_rank_compression(int capacity) {
        super(capacity);
    }

    @Override
    public int find(int v) {
        rangeCheck(v);
        int p = v;
        if (v != parent[v]) {
            p = find(parent[v]);
            parent[v] = p;
        }
        return p;
    }
}
